package cn.heygod.graywhale.runtime.task;

import cn.heygod.graywhale.runtime.context.Input;
import cn.heygod.graywhale.runtime.context.Output;
import cn.heygod.graywhale.runtime.task.exe.NodeExecutorFactory;
import lombok.Data;

/**
 * @className: TaskNode
 * @author: Simon
 * @description: TODO
 * @date: 2023/11/26 2:27
 * @version: 1.0
 */
@Data
public class TaskNode {

    private String  type ;

    private String  executor;

    private String nodeId;

    private String nodeDefId;

    private String taskName;

    private NodeStatus nodeStatus = NodeStatus.READY;


    public Output run(Input input){
        //TODO 状态-运行中
        nodeStatus = NodeStatus.RUNNING;
        Output output = NodeExecutorFactory.me().executor(this.type).run(executor,input);
        //TODO 状态-完成
        nodeStatus = NodeStatus.FINISH;
        return output;
    }

    public static enum NodeStatus{
        READY,
        RUNNING,
        FINISH
    }
}
